using System;
namespace ch.ethz.ssh2.channel
{
	
	/// <summary> ChannelOutputStream.
	/// 
	/// </summary>
	/// <author>  Christian Plattner
	/// </author>
	/// <version>  2.50, 03/15/10
	/// </version>
	public sealed class ChannelOutputStream:System.IO.Stream
	{
		internal Channel c;
		
		internal bool isClosed = false;
		
		internal ChannelOutputStream(Channel c)
		{
			this.c = c;
		}
		
		public  void  WriteByte(int b)
		{
			byte[] buff = new byte[1];
			
			buff[0] = (byte) b;
			
			Write(buff, 0, 1);
		}
		//UPGRADE_TODO: The differences in the Expected value  of parameters for method 'WriteByte'  may cause compilation errors.  "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1092'"
		public override  void  WriteByte(byte b)
		{
			WriteByte((int) b);
		}
		
		public override void  Close()
		{
			if (isClosed == false)
			{
				isClosed = true;
				c.cm.sendEOF(c);
			}
		}
		
		public override void  Flush()
		{
			if (isClosed)
				throw new System.IO.IOException("This OutputStream is closed.");
			
			/* This is a no-op, since this stream is unbuffered */
		}
		
		public override void  Write(System.Byte[] b, int off, int len)
		{
			if (isClosed)
				throw new System.IO.IOException("This OutputStream is closed.");
			
			if (b == null)
				throw new System.NullReferenceException();
			
			if ((off < 0) || (len < 0) || ((off + len) > b.Length) || ((off + len) < 0) || (off > b.Length))
				throw new System.IndexOutOfRangeException();
			
			if (len == 0)
				return ;
			
			c.cm.sendData(c, b, off, len);
		}
		
		//UPGRADE_NOTE: The equivalent of method 'java.io.OutputStream.write' is not an override method. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1143'"
		public void  write(byte[] b)
		{
			Write(b, 0, b.Length);
		}
		//UPGRADE_TODO: The following method was automatically generated and it must be implemented in order to preserve the class logic. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1232'"
		public override System.Int64 Seek(System.Int64 offset, System.IO.SeekOrigin origin)
		{
			return 0;
		}
		//UPGRADE_TODO: The following method was automatically generated and it must be implemented in order to preserve the class logic. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1232'"
		public override void  SetLength(System.Int64 value)
		{
		}
		//UPGRADE_TODO: The following method was automatically generated and it must be implemented in order to preserve the class logic. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1232'"
		public override System.Int32 Read(System.Byte[] buffer, System.Int32 offset, System.Int32 count)
		{
			return 0;
		}
		//UPGRADE_TODO: The following property was automatically generated and it must be implemented in order to preserve the class logic. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1232'"
		public override System.Boolean CanRead
		{
			get
			{
				return false;
			}
			
		}
		//UPGRADE_TODO: The following property was automatically generated and it must be implemented in order to preserve the class logic. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1232'"
		public override System.Boolean CanSeek
		{
			get
			{
				return false;
			}
			
		}
		//UPGRADE_TODO: The following property was automatically generated and it must be implemented in order to preserve the class logic. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1232'"
		public override System.Boolean CanWrite
		{
			get
			{
				return false;
			}
			
		}
		//UPGRADE_TODO: The following property was automatically generated and it must be implemented in order to preserve the class logic. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1232'"
		public override System.Int64 Length
		{
			get
			{
				return 0;
			}
			
		}
		//UPGRADE_TODO: The following property was automatically generated and it must be implemented in order to preserve the class logic. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1232'"
		public override System.Int64 Position
		{
			get
			{
				return 0;
			}
			
			set
			{
			}
			
		}
	}
}